<%@ page import="java.util.ArrayList" %>
<%@ page import="java.sql.*" %>
<%@ page import="bean.Login" %>
<%@ page import="servlet.Admin_LoginServlet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>管理员空间</title>
    <style>
        /*********** 声明公共元素样式 ***********/
        * {
            margin: 0;
            padding: 0;
        }
        body {
            background-color: #efefef;
        }
        li {
            list-style-type: none;
        }
        a {
            color:#000;
            text-decoration-line: none;
        }
        a:hover {
            color: #000000;
            text-decoration-line: underline;
        }
        /*********** 声明顶部样式 ***********/
        header {
            background: linear-gradient(to top, lightgrey, #efefef);
            margin: 10px 20px;
            overflow: hidden;
            height: 60px;
            border-bottom-left-radius: 20px;
            border-bottom-right-radius: 6px;}
        header div {
            width: 1200px;
            margin: auto;
        }
        header h1 {
            float: left;
            margin-left: 20px;
            font-weight: normal;
            line-height: 60px;
        }
        header nav {
            float: right;
            margin-right: 20px;
        }
        header nav ul li {
            float: left;
            padding-left: 30px;
            line-height: 80px;
        }
        /*********** 声明主体区样式 ***********/
        /*侧边导航栏*/
        main {
            width: 1000px;  /*内容区宽度*/
            height: 800px;
            margin: 30px auto 0;
            padding-left: 200px;
            overflow: hidden;
            /*布局参考线*/
            /*border: 1px solid red;*/
        }
        main article {
            float: left;
            /*布局参考色块*/
            /*background-color: #FD6FCF;*/
            width: 100%;
            min-height: 100%;
            background: linear-gradient(to bottom, rgba(211, 211, 211, 0.34), #ededed);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
            border-radius: 6px;
        }
        main aside {
            float: left;
            border-radius: 6px;
            background:linear-gradient(to left, rgba(206, 192, 192, 0.1), #ededed);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
            padding-bottom: 20px;
            width: 175px;
            margin-left: -100%;
            position: relative;
            left: -197px;
        }
        main aside nav li {
            line-height: 2rem;
        }
        main aside nav li:first-child,main aside nav li a{
            padding: 10px 15px;
            display: block;
        }
        main aside nav li a.active,main aside nav li a:hover {
            border-left: 3px solid #ece117 !important;
            background: rgba(211, 211, 211, 0.34);
            padding-left: 15px;
            margin-left: -3px;
        }
        main article iframe {
            min-width: 100%;
            min-height: 700px;
            margin: auto;
            border: none;
        }
        main article footer p {
            text-align: center;
        }
    </style>

</head>
<body>
<div id="main" style="width:100%;height:100%;">
    <jsp:useBean id="ad_login" class="bean.Login" scope="session"/>
    <%
        try{
            ad_login= (Login) session.getAttribute("ad_login");
            if (ad_login==null){
                response.sendRedirect("administrator_login.jsp");
                return;
            }else {
                boolean b = ad_login.getLoginID()==null || ad_login.getLoginID().length()==0;
                if (b){
                    response.sendRedirect("administrator_login.jsp");
                    return;
                }
            }
        } catch (Exception e) {
           response.sendRedirect("administrator_login.jsp");
           return;
        }
    %>
    <%!
        Connection con=null;
        Statement sql;
        ResultSet rs;
    %>
    <%!
        String hotelAddress=null,hotelName=null,passWord = null;%>
        <%
        String hotelID=ad_login.getLoginID();
//      Context context=new InitialContext();
//    Context contextNeeded =(Context) context.lookup("java:comp/env");
//    DataSource ds=(DataSource) contextNeeded.lookup("hotelConn");
        String driver="org.mariadb.jdbc.Driver";
        String url="jdbc:mariadb://localhost:3306/hotel-management-system";
        try {
            Class.forName(driver);
            con= DriverManager.getConnection(url,"root","123456");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try {
//        con=ds.getConnection();
            assert con != null;
            sql=con.createStatement();
            //读取酒店详情表
            String ex="select * from hotels where hotelID = '"+hotelID+"'";
            rs=sql.executeQuery(ex);
            while (rs.next()){
//                hotelID=rs.getString("HotelID");
                hotelAddress=rs.getString("HotelAddress");
                hotelName=rs.getString("HotelName");
                passWord= rs.getString("MpassWord");
            }
        }catch (SQLException e){
//            System.out.print(e);
        }
        finally {
            try {
                assert con != null;
                con.close();
            }catch (Exception e){
            }
        }

    %>
        <!--顶部信息区-->
        <header role="header">
            <div>
                <h1>酒店房间管理系统</h1>
                <nav role="user">
                    <ul>
                        <%--        <li><a href="modify_pass.html" target="main">修改密码</a></li>--%>
                        <li><a href="javascript:void(0);" onclick="logout()">退出登录</a></li>
                </nav>
            </div>
        </header>
        <!--圣杯二列布局-->
        <main role="main">
            <!--主体内联框架区-->
            <article role="content">
                <iframe src="html/welcome.html"  name="main"></iframe>
                <footer role="copyright">
                </footer>
            </article>
            <!--左侧导航区-->
            <aside>
                <nav role="option">
                    <ul>
                        <li>导航列表</li>
                        <li><a href="admin-equry.jsp?hotelID=<%=hotelID%>" target="main">已有房间管理</a></li>
                        <li><a href="admin-add.jsp?hotelID=<%=hotelID%>" target="main">新增房间</a></li>
                    </ul>
                </nav>
            </aside>
        </main>
</body>
</html>
<script>
    function logout() {
        if (window.confirm('是否退出?')) {
            window.location.href = 'administrator_login.jsp';
        } else {
            return false;
        }
    }
</script>
